package com.example.filter;

import javax.servlet.*;
import java.io.IOException;

public class EncodingFilter implements Filter {
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {

        //过滤请求中文乱码
        request.setCharacterEncoding("UTF-8");
        //过滤响应中文乱码
        response.setContentType("text/html;charset=UTF-8");
        //放行
        filterChain.doFilter(request,response);

    }
}
